// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class gameManager extends cc.Component {


    btnTestClick(event,data){
        if(parseInt(data) == 0){
            window["manager"].showRewardVideo("测试页面",()=>{
                this.node.getChildByName("lab_0").getComponent(cc.Label).string = "广告播放完成";
            },()=>{
                this.node.getChildByName("lab_0").getComponent(cc.Label).string = "广告播放失败";
            })
        }else if(parseInt(data) == 1){
            window["manager"].showInterstitial("测试页面",()=>{
                this.node.getChildByName("lab_0").getComponent(cc.Label).string = "广告播放完成并隐藏";
            },()=>{
                this.node.getChildByName("lab_0").getComponent(cc.Label).string = "广告播放失败";
            })
        }else if(parseInt(data) == 2){
            window["manager"].showAppOpen("测试页面",()=>{
                this.node.getChildByName("lab_0").getComponent(cc.Label).string = "广告播放完成并隐藏";
            },()=>{
                this.node.getChildByName("lab_0").getComponent(cc.Label).string = "广告播放失败";
            })
        }else if(parseInt(data) == 3){
            window["manager"].showNativeAd("测试页面",()=>{
                this.node.getChildByName("lab_0").getComponent(cc.Label).string = "广告播放完成并隐藏";
                window["manager"].destroyNativeAd();
            },()=>{
                this.node.getChildByName("lab_0").getComponent(cc.Label).string = "广告播放失败";
            })
        }else if(parseInt(data) == 4){
            window["manager"].trackEvent("测试")
        }else if(parseInt(data) == 5){
            cc.director.loadScene("LoadScene");
        }

        if(parseInt(data) == 10){
            window["manager"].trackImmediatelyEvent("测试","test1","1","test2",2)
        }

        if(parseInt(data) == 11){
            window["manager"].trackImmediatelyEvent("测试","test1","1","test2","2","test3","3")
        }
    }

    // onLoad () {}

    start () {
        this.node.getChildByName("lab_1").getComponent(cc.Label).string = cc.sys.os + "";
    }

    // update (dt) {}
}
